package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.EvnetHistory;
import com.hjxr.xmgl.web.service.IEvnetHistoryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 事件执行记录Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/history")
public class EvnetHistoryController extends BaseController
{
    @Autowired
    private IEvnetHistoryService evnetHistoryService;

    /**
     * 查询事件执行记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvnetHistory evnetHistory)
    {
        startPage();
        List<EvnetHistory> list = evnetHistoryService.selectEvnetHistoryList(evnetHistory);
        return getDataTable(list);
    }

    /**
     * 导出事件执行记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "事件执行记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EvnetHistory evnetHistory)
    {
        List<EvnetHistory> list = evnetHistoryService.selectEvnetHistoryList(evnetHistory);
        ExcelUtil<EvnetHistory> util = new ExcelUtil<EvnetHistory>(EvnetHistory.class);
        return util.exportExcel(list, "history");
    }

    /**
     * 获取事件执行记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(evnetHistoryService.selectEvnetHistoryById(id));
    }

    /**
     * 新增事件执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "事件执行记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvnetHistory evnetHistory)
    {
        return toAjax(evnetHistoryService.insertEvnetHistory(evnetHistory));
    }

    /**
     * 修改事件执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "事件执行记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvnetHistory evnetHistory)
    {
        return toAjax(evnetHistoryService.updateEvnetHistory(evnetHistory));
    }

    /**
     * 删除事件执行记录
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "事件执行记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(evnetHistoryService.deleteEvnetHistoryByIds(ids));
    }
}
